package com.fowo.api.controller.purchase;

import com.fowo.api.common.model.R;
import com.fowo.api.model.requisition.product.RequisitionProductItemVo;
import com.fowo.api.service.handleWork.RequisitionProductDServiceImpl;
import com.fowo.api.sys.entity.SysFile;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("/api/requisition-product")
@RestController
public class RequisitionDController {

    @Resource
    private RequisitionProductDServiceImpl service;

    @Operation(summary = "导入预览")
    @PostMapping("/import-preview")
    public R<List<RequisitionProductItemVo>> importPreview(@RequestBody SysFile sysFile,
                                                           @RequestParam(name = "template", required = false) Long templateId,
                                                           @RequestParam(name = "wid", required = false) Long wid,
                                                           @RequestParam(name = "toWid", required = false) Long toWid,
                                                           @RequestParam(name = "allowOverrides",defaultValue = "false"
                                                       ) boolean allowOverrides) {
        return R.data(() -> service.importPreview(sysFile,templateId,allowOverrides,wid,toWid));
    }
}
